package io.xxx.aurora.client.produce

data class ProducerRecord(
    val topic: String,
    val partition: Int?,
    val key: String? = null,
    val value: String? = null,
    val timestamp: Long? = null,
) {
    init {
        if (partition != null && partition < 0) {
            throw IllegalArgumentException("Invalid partition: $partition. Partition number should always be non-negative or null.")
        }
        if (timestamp != null && timestamp < 0) {
            throw IllegalArgumentException("Invalid timestamp: $timestamp. Timestamp should always be non-negative or null.")
        }
    }

    constructor(
        topic: String,
        partition: Int?,
        key: String?,
        value: String?,
    ) : this(topic, partition, key, value, null)

    constructor(
        topic: String,
        key: String?,
        value: String?,
    ) : this(topic, null, key, value, null)

    constructor(
        topic: String,
        partition: Int?,
        value: String?,
    ) : this(topic, partition, null, value, null)

    constructor(
        topic: String,
        value: String?,
    ) : this(topic, null, null, value, null)
}